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

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

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

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

f = A("f")
e = B("e")
i = C("i")
c = D("c")
k = B("k")
n = A("n")
h = D("h")
b = B("b")
j = A("j")

f.r = j
e.p = c
e.u = j
e.o = j
e.r = i
i.u = e
i.o = n
c.q = h
c.t = i
c.u = i
k.p = c
k.u = n
k.r = i
k.o = j
n.r = f
h.q = c
h.t = i
h.u = i
b.p = c
b.u = j
b.r = i
b.o = f
j.r = f
assert h.q.q.q.t.o.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

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

f = A("f")
e = B("e")
i = C("i")
c = D("c")
k = B("k")
n = A("n")
h = D("h")
b = B("b")
j = A("j")

f.r = j
e.p = c
e.u = j
e.o = j
e.r = i
i.u = e
i.o = n
c.q = h
c.t = i
c.u = i
k.p = c
k.u = n
k.r = i
k.o = j
n.r = f
h.q = c
h.t = i
h.u = i
b.p = c
b.u = j
b.r = i
b.o = f
j.r = f
assert h.q.q.q.t.o.r.r.txt == "j"