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

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

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

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

a = A("a")
m = B("m")
h = C("h")
b = D("b")
f = D("f")
j = D("j")
e = B("e")
k = D("k")

a.y = e
a.r = k
m.o = h
m.v = b
m.r = k
h.x = b
b.v = j
b.u = h
b.y = f
f.v = j
f.y = j
f.u = h
j.v = b
j.y = b
j.u = h
e.o = h
e.v = f
e.r = j
k.v = f
k.u = h
k.y = j
assert a.r.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.r: D = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
h = C("h")
b = D("b")
f = D("f")
j = D("j")
e = B("e")
k = D("k")

a.y = e
a.r = k
m.o = h
m.v = b
m.r = k
h.x = b
b.v = j
b.u = h
b.y = f
f.v = j
f.y = j
f.u = h
j.v = b
j.y = b
j.u = h
e.o = h
e.v = f
e.r = j
k.v = f
k.u = h
k.y = j
assert a.r.u.x.u.txt == "h"