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

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

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

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

c = A("c")
f = B("f")
k = C("k")
h = D("h")
l = D("l")

c.t = f
f.p = c
f.y = c
f.q = l
f.v = k
k.q = c
k.t = c
h.p = l
h.o = c
h.y = f
l.p = h
l.o = c
l.y = f
assert f.p.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

c = A("c")
f = B("f")
k = C("k")
h = D("h")
l = D("l")

c.t = f
f.p = c
f.y = c
f.q = l
f.v = k
k.q = c
k.t = c
h.p = l
h.o = c
h.y = f
l.p = h
l.o = c
l.y = f
assert f.p.t.q.txt == "l"