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

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

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

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

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

f.r = h
f.u = k
d.v = h
d.r = c
d.u = n
n.s = k
n.u = j
n.y = i
k.x = h
k.q = c
k.y = c
k.t = i
j.r = h
j.u = k
i.s = h
i.u = j
i.y = n
c.v = h
c.r = d
c.u = n
h.x = k
h.q = d
h.t = n
h.y = c
assert c.r.v.y.v.t.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: D = None
        self.txt = txt

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

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

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

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

f.r = h
f.u = k
d.v = h
d.r = c
d.u = n
n.s = k
n.u = j
n.y = i
k.x = h
k.q = c
k.y = c
k.t = i
j.r = h
j.u = k
i.s = h
i.u = j
i.y = n
c.v = h
c.r = d
c.u = n
h.x = k
h.q = d
h.t = n
h.y = c
assert c.r.v.y.v.t.s.x.txt == "h"