class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: C = None
        self.q: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: B = None
        self.txt = txt

i = A("i")
g = B("g")
k = C("k")
j = A("j")
h = A("h")
e = A("e")
l = B("l")
m = C("m")
f = A("f")
d = A("d")

i.y = k
i.r = k
i.q = j
g.p = i
g.x = m
k.y = m
k.x = l
j.y = k
j.r = k
j.q = h
h.y = k
h.r = k
h.q = d
e.y = m
e.r = m
e.q = j
l.p = i
l.x = m
m.y = k
m.x = l
f.y = k
f.r = m
f.q = h
d.y = k
d.r = k
d.q = j
assert e.r.y.y.y.x.p.r.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: C = None
        self.q: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: B = None
        self.txt = txt

i = A("i")
g = B("g")
k = C("k")
j = A("j")
h = A("h")
e = A("e")
l = B("l")
m = C("m")
f = A("f")
d = A("d")

i.y = k
i.r = k
i.q = j
g.p = i
g.x = m
k.y = m
k.x = l
j.y = k
j.r = k
j.q = h
h.y = k
h.r = k
h.q = d
e.y = m
e.r = m
e.q = j
l.p = i
l.x = m
m.y = k
m.x = l
f.y = k
f.r = m
f.q = h
d.y = k
d.r = k
d.q = j
assert e.r.y.y.y.x.p.r.x.p.txt == "i"