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

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

class C:
    def __init__(self, txt: str):
        self.w: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

d = A("d")
k = B("k")
i = C("i")
h = D("h")
e = E("e")
n = F("n")
c = G("c")

d.o = i
k.u = i
i.w = n
h.w = i
h.r = i
h.z = k
e.u = i
n.x = k
c.t = h
assert d.o.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

d = A("d")
k = B("k")
i = C("i")
h = D("h")
e = E("e")
n = F("n")
c = G("c")

d.o = i
k.u = i
i.w = n
h.w = i
h.r = i
h.z = k
e.u = i
n.x = k
c.t = h
assert d.o.w.x.txt == "k"