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

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

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

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

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

b.u = k
c.o = i
c.y = b
e.r = i
h.q = b
h.w = k
a.o = b
a.y = i
l.q = b
l.w = a
g.r = b
i.u = c
f.o = i
f.y = b
k.o = i
k.y = b
assert e.r.u.o.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

b.u = k
c.o = i
c.y = b
e.r = i
h.q = b
h.w = k
a.o = b
a.y = i
l.q = b
l.w = a
g.r = b
i.u = c
f.o = i
f.y = b
k.o = i
k.y = b
assert e.r.u.o.u.o.txt == "i"