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

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

class C:
    def __init__(self, txt: str):
        self.u: C = None
        self.v: B = None
        self.txt = txt

h = A("h")
b = B("b")
a = C("a")
k = C("k")
d = B("d")
i = A("i")
c = C("c")
j = C("j")
f = C("f")
e = B("e")

h.r = i
h.y = f
h.q = k
b.y = k
b.u = i
a.u = j
a.v = e
k.u = j
k.v = e
d.y = c
d.u = i
i.r = h
i.y = a
i.q = k
c.u = j
c.v = d
j.u = c
j.v = b
f.u = k
f.v = e
e.y = a
e.u = i
assert h.r.q.u.u.u.v.u.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: C = None
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: C = None
        self.v: B = None
        self.txt = txt

h = A("h")
b = B("b")
a = C("a")
k = C("k")
d = B("d")
i = A("i")
c = C("c")
j = C("j")
f = C("f")
e = B("e")

h.r = i
h.y = f
h.q = k
b.y = k
b.u = i
a.u = j
a.v = e
k.u = j
k.v = e
d.y = c
d.u = i
i.r = h
i.y = a
i.q = k
c.u = j
c.v = d
j.u = c
j.v = b
f.u = k
f.v = e
e.y = a
e.u = i
assert h.r.q.u.u.u.v.u.r.r.txt == "i"