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

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.w: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.v: D = None
        self.w: C = None
        self.t: B = None
        self.txt = txt

b = A("b")
i = B("i")
d = C("d")
a = D("a")
f = B("f")
c = D("c")
h = C("h")
m = B("m")
e = D("e")

b.r = h
i.y = b
i.r = f
i.p = h
i.q = h
d.q = c
d.w = f
a.o = b
a.v = c
a.w = h
a.t = m
f.y = b
f.r = i
f.p = h
f.q = d
c.o = b
c.v = a
c.w = h
c.t = m
h.q = e
h.w = m
m.y = b
m.r = f
m.p = d
m.q = h
e.o = b
e.v = c
e.w = h
e.t = f
assert b.r.q.t.p.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.w: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.v: D = None
        self.w: C = None
        self.t: B = None
        self.txt = txt

b = A("b")
i = B("i")
d = C("d")
a = D("a")
f = B("f")
c = D("c")
h = C("h")
m = B("m")
e = D("e")

b.r = h
i.y = b
i.r = f
i.p = h
i.q = h
d.q = c
d.w = f
a.o = b
a.v = c
a.w = h
a.t = m
f.y = b
f.r = i
f.p = h
f.q = d
c.o = b
c.v = a
c.w = h
c.t = m
h.q = e
h.w = m
m.y = b
m.r = f
m.p = d
m.q = h
e.o = b
e.v = c
e.w = h
e.t = f
assert b.r.q.t.p.q.w.txt == "h"