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

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

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

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

n = A("n")
g = B("g")
f = C("f")
e = D("e")
a = B("a")
c = B("c")
i = A("i")
d = B("d")
b = B("b")

n.u = d
n.r = i
n.x = e
n.t = e
g.y = f
f.t = i
f.p = n
f.s = e
e.y = c
e.q = f
a.y = f
c.y = f
i.u = b
i.r = n
i.x = e
i.t = e
d.y = f
b.y = f
assert g.y.t.r.t.y.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: A = None
        self.x: D = None
        self.t: D = None
        self.txt = txt

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

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

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

n = A("n")
g = B("g")
f = C("f")
e = D("e")
a = B("a")
c = B("c")
i = A("i")
d = B("d")
b = B("b")

n.u = d
n.r = i
n.x = e
n.t = e
g.y = f
f.t = i
f.p = n
f.s = e
e.y = c
e.q = f
a.y = f
c.y = f
i.u = b
i.r = n
i.x = e
i.t = e
d.y = f
b.y = f
assert g.y.t.r.t.y.y.t.txt == "i"