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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.w: C = None
        self.p: A = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
f = C("f")
j = D("j")
e = B("e")
g = A("g")

l.q = f
l.p = j
c.o = j
c.w = f
c.p = l
f.v = c
f.q = j
j.t = l
j.x = f
e.o = j
e.w = f
e.p = g
g.q = f
g.p = j
assert f.q.x.q.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.w: C = None
        self.p: A = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
f = C("f")
j = D("j")
e = B("e")
g = A("g")

l.q = f
l.p = j
c.o = j
c.w = f
c.p = l
f.v = c
f.q = j
j.t = l
j.x = f
e.o = j
e.w = f
e.p = g
g.q = f
g.p = j
assert f.q.x.q.x.v.txt == "c"