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

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

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

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

g = A("g")
j = B("j")
n = C("n")
i = D("i")
f = A("f")
a = B("a")
h = C("h")

g.t = h
g.u = j
g.q = f
g.x = f
j.x = a
n.r = i
i.u = h
f.t = h
f.u = a
f.q = g
f.x = g
a.x = j
h.r = i
assert i.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.u: B = None
        self.q: A = None
        self.x: A = None
        self.txt = txt

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

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

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

g = A("g")
j = B("j")
n = C("n")
i = D("i")
f = A("f")
a = B("a")
h = C("h")

g.t = h
g.u = j
g.q = f
g.x = f
j.x = a
n.r = i
i.u = h
f.t = h
f.u = a
f.q = g
f.x = g
a.x = j
h.r = i
assert i.u.r.u.txt == "h"