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

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

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

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

g = A("g")
f = B("f")
h = C("h")
d = D("d")
l = C("l")
j = A("j")
a = B("a")
k = C("k")
e = D("e")

g.q = a
f.u = e
f.v = k
f.r = g
f.q = a
h.x = e
d.t = j
l.x = d
j.q = f
a.u = d
a.v = k
a.r = j
a.q = f
k.x = e
e.t = j
assert l.x.t.q.v.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

g = A("g")
f = B("f")
h = C("h")
d = D("d")
l = C("l")
j = A("j")
a = B("a")
k = C("k")
e = D("e")

g.q = a
f.u = e
f.v = k
f.r = g
f.q = a
h.x = e
d.t = j
l.x = d
j.q = f
a.u = d
a.v = k
a.r = j
a.q = f
k.x = e
e.t = j
assert l.x.t.q.v.x.t.txt == "j"