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

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

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

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

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

f.t = l
l.y = c
j.r = f
j.x = f
j.t = k
k.q = f
c.y = l
assert k.q.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

f.t = l
l.y = c
j.r = f
j.x = f
j.t = k
k.q = f
c.y = l
assert k.q.t.y.txt == "c"