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

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

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

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

b = A("b")
h = B("h")
e = C("e")
m = D("m")
n = A("n")
d = B("d")
j = B("j")
i = A("i")
l = C("l")
g = C("g")

b.r = l
b.x = j
h.z = i
h.r = d
e.p = g
m.v = h
m.u = g
n.r = g
n.x = j
d.z = b
d.r = j
j.z = i
j.r = h
i.r = e
i.x = h
l.p = e
g.p = l
assert e.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: B = None
        self.txt = txt

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

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

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

b = A("b")
h = B("h")
e = C("e")
m = D("m")
n = A("n")
d = B("d")
j = B("j")
i = A("i")
l = C("l")
g = C("g")

b.r = l
b.x = j
h.z = i
h.r = d
e.p = g
m.v = h
m.u = g
n.r = g
n.x = j
d.z = b
d.r = j
j.z = i
j.r = h
i.r = e
i.x = h
l.p = e
g.p = l
assert e.p.p.p.p.txt == "g"