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

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

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

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

g = A("g")
k = B("k")
d = C("d")
n = D("n")

g.q = d
g.v = d
g.y = n
g.u = n
k.y = g
k.t = n
d.u = g
d.y = k
n.q = g
assert d.u.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.y: D = None
        self.u: D = None
        self.v: C = None
        self.txt = txt

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

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

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

g = A("g")
k = B("k")
d = C("d")
n = D("n")

g.q = d
g.v = d
g.y = n
g.u = n
k.y = g
k.t = n
d.u = g
d.y = k
n.q = g
assert d.u.y.q.txt == "g"