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

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

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

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

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

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

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

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

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

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

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