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

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: A = None
        self.w: C = None
        self.z: D = None
        self.txt = txt

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

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

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

k.z = g
c.v = h
c.z = h
c.r = k
c.w = g
g.t = c
g.x = h
g.v = k
h.o = c
h.q = k
h.s = g
assert c.r.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: A = None
        self.w: C = None
        self.z: D = None
        self.txt = txt

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

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

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

k.z = g
c.v = h
c.z = h
c.r = k
c.w = g
g.t = c
g.x = h
g.v = k
h.o = c
h.q = k
h.s = g
assert c.r.z.x.txt == "h"