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

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

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

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

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

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

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

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

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

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

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