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

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

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

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

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

h.p = f
h.u = b
b.r = f
b.o = h
a.t = m
a.u = m
c.r = g
c.z = b
c.o = m
n.r = g
n.z = b
n.o = m
g.t = h
g.u = l
k.t = m
k.u = m
l.p = f
l.u = b
m.p = b
m.u = f
f.r = b
f.o = l
assert b.o.u.o.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: B = None
        self.txt = txt

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

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

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

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

h.p = f
h.u = b
b.r = f
b.o = h
a.t = m
a.u = m
c.r = g
c.z = b
c.o = m
n.r = g
n.z = b
n.o = m
g.t = h
g.u = l
k.t = m
k.u = m
l.p = f
l.u = b
m.p = b
m.u = f
f.r = b
f.o = l
assert b.o.u.o.u.r.txt == "f"