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

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

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

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

j = A("j")
c = B("c")
a = C("a")
h = D("h")
b = A("b")
l = B("l")
e = D("e")
d = D("d")
f = D("f")

j.y = a
j.q = a
c.v = f
c.s = h
c.q = b
c.t = d
a.t = j
a.x = f
h.r = a
h.o = a
h.q = b
b.y = a
b.q = a
l.v = h
l.s = e
l.q = b
l.t = f
e.r = a
e.o = a
e.q = j
d.r = a
d.o = a
d.q = j
f.r = a
f.o = a
f.q = j
assert j.y.x.r.x.q.q.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: C = None
        self.txt = txt

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

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

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

j = A("j")
c = B("c")
a = C("a")
h = D("h")
b = A("b")
l = B("l")
e = D("e")
d = D("d")
f = D("f")

j.y = a
j.q = a
c.v = f
c.s = h
c.q = b
c.t = d
a.t = j
a.x = f
h.r = a
h.o = a
h.q = b
b.y = a
b.q = a
l.v = h
l.s = e
l.q = b
l.t = f
e.r = a
e.o = a
e.q = j
d.r = a
d.o = a
d.q = j
f.r = a
f.o = a
f.q = j
assert j.y.x.r.x.q.q.x.o.txt == "a"