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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.t: D = None
        self.r: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

m = A("m")
l = B("l")
d = C("d")
i = D("i")
f = D("f")
b = A("b")
a = C("a")
h = D("h")
g = B("g")
k = B("k")

m.q = i
m.r = i
l.y = m
l.r = m
l.t = h
d.w = f
i.o = g
f.o = k
b.q = h
b.r = f
a.w = i
h.o = g
g.y = b
g.r = b
g.t = h
k.y = m
k.t = f
k.r = b
assert h.o.t.o.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.t: D = None
        self.r: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

m = A("m")
l = B("l")
d = C("d")
i = D("i")
f = D("f")
b = A("b")
a = C("a")
h = D("h")
g = B("g")
k = B("k")

m.q = i
m.r = i
l.y = m
l.r = m
l.t = h
d.w = f
i.o = g
f.o = k
b.q = h
b.r = f
a.w = i
h.o = g
g.y = b
g.r = b
g.t = h
k.y = m
k.t = f
k.r = b
assert h.o.t.o.y.q.txt == "h"