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

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

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

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

f = A("f")
n = B("n")
b = C("b")
e = D("e")
m = C("m")
l = B("l")
j = D("j")
h = D("h")

f.r = e
n.w = f
n.r = f
n.o = f
n.p = e
b.o = f
b.u = f
e.q = n
m.o = f
m.u = f
l.w = f
l.r = f
l.o = f
l.p = j
j.q = l
h.q = l
assert m.u.r.q.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

f = A("f")
n = B("n")
b = C("b")
e = D("e")
m = C("m")
l = B("l")
j = D("j")
h = D("h")

f.r = e
n.w = f
n.r = f
n.o = f
n.p = e
b.o = f
b.u = f
e.q = n
m.o = f
m.u = f
l.w = f
l.r = f
l.o = f
l.p = j
j.q = l
h.q = l
assert m.u.r.q.p.q.txt == "n"